<!DOCTYPE html>
<html lang="en">

<head>
    <title>
        <%- result.title %>
    </title>
    <%- include common %>
        <style>
            .movie-box {
                box-sizing: border-box;
                border-right: 2px solid #999;
                border-left: 2px solid #999;
            }

            .movie-box h2 {
                margin-bottom: 30px;
            }

            .img-box {
                height: 500px;
                text-align: center;
            }

            .img-box img {
                height: 100%;
            }

            .movie-text {
                padding: 0 20%;
            }
        </style>
</head>

<body>
    <%- include('head',{title:'movie',username:username })%>
        <div class="container">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-md-6 movie-box">
                        <h2 class="text-success text-center"> 《<%-result.title %>》电影详情</h2>
                        <div class="mv-item">
                            <div class="list-box">
                                <div class="img-box">
                                    <img src="<%- result.images.large.replace(/img7/,'img3') %>" alt="">
                                </div>
                                <div class="movie-text">
                                    <h4 class="text-success">
                                        <%- result.title%>
                                    </h4>
                                    <p>年份: <%- result.year%>
                                    </p>
                                    <p>导演: <%- result.directors[0].name %>
                                    </p>
                                    <p>评分: <%- result.rating.average%>
                                    </p>
                                    <p>分类: <%- result.genres %>
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="content">内容</label>
                            <textarea class="form-control" name="content" id="content" cols="30" rows="10"
                                placeholder="Content"></textarea>
                        </div>
                        <button type="submit" id="com-submit-btn" class="btn btn-success">提交评论</button>
                    </div>
                </div>
            </div>
        </div>
        <script>
            



            $(document).on("click", "#com-submit-btn", function () {
                $.ajax({
                    url: `/comment/insert?mid=${$(".comment-input").attr("data-mid")}`,
                    type: "post",
                    data: {
                        title: $("#title").val(),
                        content: $("#content").val(),
                    },
                    success() {
                        location.href = `/comment/mlist?mid=${$(".comment-input").attr("data-mid")}`;
                    }
                })
            })


            // $("#content").xheditor(); // 简单的实例化 
            $(pageInit);
            function pageInit() {
                $.extend(XHEDITOR.settings, { shortcuts: { "ctrl+enter": submitForm } });
                // $("#ele").xheditor();
                $("#content").xheditor({   //初始化 富文件编辑框
                    html5Upload: false,
                    upMultiple: "1",

                    upLinkRrl: "upload.html",
                    upLinkExt: "zip,rar,txt",

                    upImgUrl: "/comment/uploadImg",   // 图片上传的服务器  
                    upImgExt: "jpg,jpeg,gif,png",

                    upFlashUrl: "upload.php",
                    upFlashExt: "swf",

                    upMediaUrl: "upload.php",
                    upMediaExt: "wmv,avi,wma,mp3,mid"

                });
            };

            function insertUpload(arrMsg) {
                console.log(arrMsg);
                var i, msg;
                for (var i = 0; i < arrMsg.length; i++) {
                    msg = arrMsg[i];
                    console.log(msg);
                    $("#uploadList").append('<option value="' + msg.id + '">' + msg.localname + '</option>')
                }
            };

            function submitForm() {
                $("#frmDemo").submit();
            }

        </script>
</body>

</html>